//
//  MCGoodsDetailSpecificationsCell.swift
//  StoreManage
//
//  Created by MC on 2018/2/6.
//  Copyright © 2018年 MC. All rights reserved.
//

import UIKit

class MCGoodsDetailSpecificationsCell: UITableViewCell {

    var model : MCGoodsDetailSpecificationsModel = MCGoodsDetailSpecificationsModel() {
        didSet {
            iconImageView.sd_setImage(with: URL.init(string: model.imagePath), placeholderImage: #imageLiteral(resourceName: "Reuse_placeholder_1_1"))
            orderLabel.text = "货号:" + model.productBn
            barCodeLabel.text = "条形码:" + model.barCode
            specLabel.text = "规格:" + model.specification
        }
    }
    
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.backgroundColor = UIColor.white
        
        self.addSubview(lineView)
        lineView.snp.remakeConstraints { (make) ->Void in
            make.left.right.bottom.equalTo(self)
            make.height.equalTo(1)
        }
        
        self.addSubview(iconImageView)
        iconImageView.snp.remakeConstraints { (make) ->Void in
            make.centerY.equalTo(self)
            make.left.equalTo(15)
            make.size.equalTo(CGSize.init(width: 80, height: 80))
        }
        
        self.addSubview(orderLabel)
        orderLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(iconImageView.snp.right).offset(10)
            make.top.equalTo(iconImageView).offset(3)
            make.right.equalTo(-10)
        }
        
        self.addSubview(barCodeLabel)
        barCodeLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(iconImageView.snp.right).offset(10)
            make.centerY.equalTo(iconImageView)
            make.right.equalTo(-10)
        }

        
        self.addSubview(specLabel)
        specLabel.snp.remakeConstraints { (make) ->Void in
            make.left.equalTo(iconImageView.snp.right).offset(10)
            make.bottom.equalTo(iconImageView).offset(-3)
            make.right.equalTo(-10)
        }

    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy var lineView: UIView = {
        let view = UIView()
        view.backgroundColor = UIColor.MCGray_light
        return view
    }()
    
    lazy var iconImageView: UIImageView = {
        let imageView = UIImageView()
        imageView.image = #imageLiteral(resourceName: "Reuse_placeholder_1_1")
        return imageView
    }()
    
    lazy var orderLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(12)
        label.textColor = UIColor.MCGray_middle
        return label
    }()
    
    lazy var barCodeLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(12)
        label.textColor = UIColor.MCGray_middle
        label.text = "条形码:"
        return label
    }()
    
    lazy var specLabel: UILabel = {
        let label = UILabel()
        label.font = MCFont(12)
        label.textColor = UIColor.MCGray_middle
        label.text = "规格:"
        return label
    }()
    
}
